import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

var r = require.context("../views", true, /\.router\.js/);

var arr = [];

r.keys().forEach(item => {
  arr = arr.concat(r(item).default);
});
console.log(arr);

const routes = [
  {
    path: "/",
    component: Home
  },
  {
    path: "/about",
    component: () => import("../views/About.vue")
  },
  ...arr
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
